import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

regions = ['华东', '西北', '东北', '华北', '华南']
completion_rates = [35, 51, 62, 74, 86]
not_completion_rates = [65, 49, 38, 26, 14]
colors = ['#ff9999', '#66b3ff', '#99ff99', '#ffcc99', '#c2c2f0']

fig, ax = plt.subplots(figsize=(10, 6))

for i in range(len(regions)):
    ax.barh(i, completion_rates[i], color=colors[i], edgecolor='white', height=0.4)
    ax.barh(i, not_completion_rates[i], left=completion_rates[i], color='lightgray', edgecolor='white', height=0.4)

    ax.plot(completion_rates[i], i, 'o', markersize=40, color=colors[i], markeredgewidth=2, markeredgecolor='white')

    ax.text(completion_rates[i], i, f"{completion_rates[i]}%", va='center', ha='center', color='white', fontsize=20,
            fontweight='bold')

ax.set_xlabel('百分比 (%)')
ax.set_title('2022年上半年产品销量目标达成率情况\n华南完成率最高达到86%，华东最低35%')
ax.set_yticks(range(len(regions)))
ax.set_yticklabels(regions)
ax.invert_yaxis()

plt.figtext(0.1, -0.05, '*注：数据源于公司销售系统，统计日期截至2022.06.30', ha="left", fontsize=10, color="grey")

plt.xlim(0, 100)
plt.grid(axis='x', linestyle='--', alpha=0.7)

#plt.savefig('D:/python charm/01/可视化/第二章/图片/滑珠图.png')

plt.show()